package com.longyou.gateway.security.controller;

import com.longyou.gateway.util.IPUtils;
import org.cloud.vo.CommonApiResult;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping(value = "/uFJeYgDVpgmB", produces = MediaType.APPLICATION_JSON_VALUE)
@Transactional(propagation = Propagation.NEVER)
public class HealthController {

    @GetMapping
    public Mono<CommonApiResult<Integer>> getAuthentication() {
        return Mono.just(CommonApiResult.createSuccessResult(200));
    }

//    @GetMapping("getIp")
//    public Mono<CommonApiResult<String>> getIp(ServerHttpRequest request) {
//        return Mono.just(CommonApiResult.createSuccessResult(IPUtils.getIpAddress(request)));
//    }

//    @GetMapping("getAllHeader")
//    public Mono<CommonApiResult<String>> getAllHeader(ServerHttpRequest request) {
//        HttpHeaders headers = request.getHeaders();
//        // Create a StringBuilder to store headers
//        StringBuilder headersInfo = new StringBuilder();
//        headers.forEach((key, value) -> headersInfo.append(key).append(": ").append(String.join(",", value)).append("\n"));
//        // Return headers as a Mono responses
//        return Mono.just(CommonApiResult.createSuccessResult(headersInfo.toString()));
//    }
}
